
public class VectorClock {
    public int[] clock;
    int myId;
    public VectorClock(int id) {
        int numServers = Constants.NUM_SERVERS; 
    	myId = id;
        clock = new int[numServers];
        for (int i = 0; i < numServers; i++) clock[i] = 0;
        clock[myId] = 1;
    }
    public int getValue(int i) {
        return clock[i];
    }
    public void tick() {
        clock[myId]++;
    }
    public void sendAction() {
        tick();
    }
    public void receiveAction(int sender, int sentValue) {
        clock[sender] = max(clock[sender], sentValue);
        clock[myId] = max(clock[myId], sentValue) + 1;
    }
    
    public static int max(int a, int b) {
      if (a > b) return a;
      return b;
  }
}

